package com.cskaoyan.resultset;

import com.cskaoyan.bean.Account;
import org.apache.commons.dbutils.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * 创建日期: 2022/07/02 10:23
 *
 * @author ciggar
 */
public class MyResultSetHandler implements ResultSetHandler<Account> {
    @Override
    public Account handle(ResultSet resultSet) throws SQLException {
        resultSet.next();

        int id = resultSet.getInt("id");
        String name = resultSet.getString("name");
        int money = resultSet.getInt("money");

        Account account = new Account();
        account.setId(id);
        account.setName(name);
        account.setMoney(money);

        return account;
    }
}
